/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ACH.app.util;

import cenidet.object.api.LinguisticPhenomAPI;
import java.sql.SQLException;
/**
 *
 * @author adriancruz11c
 */
public class Synonym extends General{
    
    public static boolean isSynonymOfWordNet(String ul1, String ul2, LinguisticPhenomAPI myApi) throws SQLException {                
        if (SizeSynonymOfWordNet(ul1, ul2, myApi)>0.0)
            return true;        
     return false;
    }
    public static double SizeSynonymOfWordNet(String ul1, String ul2, LinguisticPhenomAPI myApi) throws SQLException {        
        String []Aul1=getSynonymsWordNt(ul1, myApi);       
        String []Aul2=getSynonymsWordNt(ul2, myApi);       
        //String queryAnt= getStrQAnt(ul1, ul2);
        double matchArrays = matchArrays(Aul1, Aul2);                
     return matchArrays;
    }
    private static String[] getSynonymsWordNt(String ul,  LinguisticPhenomAPI myApi) throws SQLException {
        String SynonymAPI = myApi.getSynsetsAPI(ul,"English");                
        /*
        //System.out.println("senses Synonymous of " +ul +" Start:");
        String []SynonymAPI2=SynonymAPI.split(":");  
        for (String x: SynonymAPI2)
            System.out.println(x);
        System.out.println("senses Synonymous of " +ul +" END:");        */
        
        return SynonymAPI.split(":");                   
    }
    /*
    //SizeSynonymOfPatternWeb
    public static JSONObject getJSONPatternWeb(String ul1, String ul2,ReadingDataDB.ObjData dat) throws SQLException, IOException, JSONException {        
        String q=""+getStrQAnt(ul1,ul2)+" " + getStrQAnt(ul2,ul1);
        q= q.substring(0, q.length()-3);        
        return Search.readJsonFromQ(q,"",1,dat);
    }
     public static long totalResults(JSONObject json){
         Search se= new Search();
         return se.totalResults(json);
     }
    
    
    private static String getStrQAnt(String ul1, String ul2) {
        String queryAnt="\"the " +ul1 + " and other " +ul2 + "\" OR " +
                        "\"the " + ul1 +" is a "+ul2 +" of" + "\" OR " +
                        "\"the " +ul1+ " is a " +ul2+ " that" + "\" OR "+
                        "\"the " + ul1+ " is the single " +ul2+ "\" OR "+
                        "\"the " +ul1+ " is one of the " +ul2+ " more" + "\" OR "+
                        "\"the " +ul1+ " are a " +ul2+ "\" OR " +
                        "\"the use of " +ul1+ " as " +ul2+ "\" OR ";
     return queryAnt;
    }
    public static double sizeAntWeb(JSONObject json){
        double t=totalResults(json);
        double tlog=0.0;
        if (t>0){
            tlog=Math.log10(t/10);
            if (tlog>1.0) tlog=1.0;
        }
        return tlog;
    }*/
}
